
def get_posts(blog_id, serverRelativeUrl='home'):
	tag = serverRelativeUrl.replace('/', '-')
	if not tag or tag == '-' or tag == 'all':
		url = 'http://www.blogger.com/feeds/%s/posts/default' % (blog_id)
	else:
		url = 'http://www.blogger.com/feeds/%s/posts/default/-/%s' % (blog_id, tag)
	
	result = urlfetch.fetch(url) 
	feed = ElementTree.fromstring(result.content)
	atomNS = 'http://www.w3.org/2005/Atom'
	xentries = feed.findall('.//{%s}entry' % atomNS)
	
	posts = []
	for xentry in xentries:
		url = ''
		xlinks = xentry.findall('{%s}link' % atomNS)
		for xlink in xlinks:
			type = xlink.get('type')
			if type=='text/html':
				url = xlink.get('href')
	
	posts.append(
		{
			'title': xentry.find('{%s}title' % atomNS).text,
			'body': xentry.find('{%s}content' % atomNS).text,
			'url': url,
			'published': xentry.find('{%s}published' % atomNS).text,
			'updated': xentry.find('{%s}updated' % atomNS).text
		}
	)
	
	return posts




#def get_albums(user_id='simon.clint', tag='all', cacheduration=60*60*5):
#    url = 'http://picasaweb.google.com/data/feed/api/user/%s' % (user_id)
#    
#    ckey = ':%s#albums' % (url)
#    
#    #if CACHE_REMOTE_DATA:
#    #    albums = memcache.get(ckey)
#    #    if albums:
#    #        return albums
#    
#    result = urlfetch.fetch(url)
#
#    feed = ElementTree.fromstring(result.content)
#
#    atomNS = 'http://www.w3.org/2005/Atom'
#    exifNS = 'http://schemas.google.com/photos/exif/2007'
#    geoNS = 'http://www.w3.org/2003/01/geo/wgs84_pos#'
#    gmlNS = 'http://www.opengis.net/gml'
#    georssNS = 'http://www.georss.org/georss'
#    batchNS = 'http://schemas.google.com/gdata/batch'
#    mediaNS = 'http://search.yahoo.com/mrss/'
#    gphotoNS = 'http://schemas.google.com/photos/2007'
#    
#    fid = feed.find('{%s}id' % (atomNS)).text
#    xentries = feed.findall('.//{%s}entry' % atomNS)
#
#    albums = []
#    for xentry in xentries:
#        url = ''
#        xlinks = xentry.findall('{%s}link' % atomNS)
#        for xlink in xlinks:
#            type = xlink.get('type')
#            if type=='text/html':
#                url = xlink.get('href')
#        
#        xthumbnail = xentry.find('{%s}group/{%s}thumbnail' % (mediaNS, mediaNS))
#        
#        albums.append({
#            'id': xentry.find('{%s}id' % atomNS).text,
#            'url': url,
#            'title': xentry.find('{%s}title' % atomNS).text,
#            'published': xentry.find('{%s}published' % atomNS).text,
#            'updated': xentry.find('{%s}updated' % atomNS).text,
#            'count': xentry.find('{%s}numphotos' % gphotoNS).text,
#            'thumbnail': {
#                'url': xthumbnail.get('url'),
#                'width': xthumbnail.get('width'),
#                'height': xthumbnail.get('height')
#            }
#            #'bytes': xentry.find('{%s}bytesUsed' % gphotoNS).text
#        })
#        
#    #if CACHE_REMOTE_DATA:
#    #    memcache.add(ckey, albums, cacheduration)
#        
#    return albums
